home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Demos / Extend 3.0 Demo / Demo Libraries / Demo Generic Lib / Demo Generic Lib.rsrc / MODL_7113_Add < prev    next >
Encoding:
Text File  |  1994-06-22  |  2.1 KB  |  70 lines

  1. double    timeArray[];
  2.  
  3. ** This block adds the inputs and outputs their sum.
  4. ** Copyright © 1989-1994 by  Imagine That, Inc.
  5. **    All Rights Reserved.
  6. ** Extend Generic Library, Add block; Alfy Riddle
  7. **        modified     1/1/92    JSL modified for V2.0
  8. **                    2/14/94 DJK modified trace and report
  9. **                    3/10/94 DJK added block label to trace & report
  10.  
  11.  
  12.  
  13. procedure calc()
  14. {
  15.     conOut = con1In + con2In + con3In;
  16.  
  17.     ** sysglobal2 is the file reference number for the DEBUG TRACE
  18.     if( sysGlobal2 != 0.0 ) ** 0 is error, check for open file for TRACE
  19.         {
  20. // template for report:      |BLOCK NAME *****************|block number |BLOCK NUMBER*******
  21.         fileWrite(sysGlobal2,"Add                          block number "+(MyBlockNumber())+".  Current Time:"+currentTime+".","",True);
  22.         if(getBlockLabel(myBlockNumber()) != "")
  23.             fileWrite(sysGlobal2,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
  24.         fileWrite(sysGlobal2,"     Top Input = "+con1In,"",True);
  25.         fileWrite(sysGlobal2,"     Mid Input = "+con2In,"",True);
  26.         fileWrite(sysGlobal2,"     Bot Input = "+con3In,"",True);
  27.         fileWrite(sysGlobal2,"     Output = "+conOut,"",True);
  28.         fileWrite(sysGlobal2," ","",True);
  29.         }
  30. }
  31.  
  32.  
  33. ** This message occurs for each step in the simulation.
  34. on Simulate
  35. {
  36.     calc();
  37. }
  38.  
  39.  
  40. **     If the dialog data is inconsistent for simulation, abort.
  41. **    check connections during checkData
  42. on checkData
  43. {
  44.     sysGlobal1 = 0.0;    ** prevent false reports
  45.     sysGlobal2 = 0.0;    ** prevent false debugs
  46. }
  47.  
  48.  
  49. ** Initialize any simulation variables.
  50. on initSim
  51. {
  52.     if( getPassedArray(sysGlobal0, timeArray) )
  53.         getSimulateMsgs(FALSE);
  54. }
  55.  
  56.  
  57. on endSim
  58. {
  59.     ** sysGlobal1 is the file reference number for the TEXT REPORT
  60.     if( sysGlobal1 != 0.0 )  ** 0 is error, check for open file for REPORT
  61.         {
  62. // template for report:      |BLOCK NAME *****************|block number |BLOCK NUMBER*******
  63.         fileWrite(sysGlobal1,"Add                          block number "+MyBlockNumber(),"",True);
  64.         if(getBlockLabel(myBlockNumber()) != "")
  65.             fileWrite(sysGlobal1,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
  66.         if( comments != "" )
  67.             fileWrite(sysGlobal1,"Comments = "+comments,"",True);        
  68.         fileWrite(sysGlobal1," ","",True);
  69.         }
  70. }